/************************************************************************
*
*    File Name: playerplane.cpp
*    Description: 编写玩家飞机类  加载图片，启动定时器，每隔一段时间判断飞机移动
*    Version: V2.0
*    Author: 王涵
*    Create Time: 2024-11-27
*
*************************************************************************/
#include "playerplane.h"

PlayerPlane::PlayerPlane(QObject *parent) : QObject(parent)
  ,speed(PLANE_SPEED),blood(100)
{

    // 启动飞机移动timer
    QTimer *timer = new QTimer(this);
    connect(timer,&QTimer::timeout,this,&PlayerPlane::player_plane_move);
    timer->start(16);
}

void PlayerPlane::picture_choose(int path){
    // 选择皮肤
    switch (path){
    case 1:
        plane_picture.load(PLANE_PATH_1);
        break;
    case 2:
        plane_picture.load(PLANE_PATH_2);
        break;
    case 3:
        plane_picture.load(PLANE_PATH_3);
    }
    setPixmap(plane_picture.scaled(PLANE_WIDTH,PLANE_HEIGHT));
}

void PlayerPlane::setup(int a)
{
    up = a;
}

void PlayerPlane::setdown(int a)
{
    down = a;
}

void PlayerPlane::setleft(int a)
{
    left = a;
}

void PlayerPlane::setright(int a)
{
    right = a;
}
